package com.superteam.zzl.model.DynamicFragment;

import com.superteam.zzl.cans.Url;
import com.superteam.zzl.model.DynamicFragment.bean.Group;
import com.superteam.zzl.model.DynamicFragment.bean.Info;
import com.superteam.zzl.retrofit.DynamicFragment.IInfoRetrofit;
import com.superteam.zzl.retrofit.DynamicFragment.custom.InfoInterceptor;

import okhttp3.OkHttpClient;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import retrofit2.converter.scalars.ScalarsConverterFactory;

/**
 * Created by Administrator on 2017/1/14.
 */

public class MInfo {

    private Callback callback;
    private String id;

    public MInfo(Callback callback) {
        this.callback = callback;
    }

    public void loadDada(String id) {

        OkHttpClient client = new OkHttpClient.Builder().addInterceptor(new InfoInterceptor()).build();
        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl(Url.baseUrl)
                .addConverterFactory(ScalarsConverterFactory.create())
                .addConverterFactory(GsonConverterFactory.create())
                .client(client)
                .build();


        IInfoRetrofit iInfoRetrofit = retrofit.create(IInfoRetrofit.class);
        Call<Info> info = iInfoRetrofit.sendInfoDada("info", id);
        Call<Group> groups = iInfoRetrofit.sendGroupData("groups", id);
        info.enqueue(callback);
        groups.enqueue(callback);
    }

}
